from django.core.management.base import BaseCommand
from Medicinal.models import CategoryHead

class Command(BaseCommand):
    help = '添加中药材分类数据'

    def handle(self, *args, **options):
        categories = [
            '电子产品',
            '根及根茎类',
            '果实和种子类',
            '全草类',
            '花类',
            '叶类',
            '皮类',
            '茎木类',
            '动物类药材',
            '矿物类药材',
            '树脂类',
            '菌藻类',
            '其它'
        ]

        for category_name in categories:
            CategoryHead.objects.get_or_create(
                name=category_name
            )

        self.stdout.write(self.style.SUCCESS('成功添加所有分类数据'))